<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    <input type="text" id="username"><br>
    <input type="text" id="password"><br>
    <input type="button" value="登录" id="btn">
</body>
<script>

    const un = document.querySelector("#username")
    const pw = document.querySelector("#password")
    const login = document.querySelector("#btn")

    let url = "http://10.11.60.96:3000/login";


    login.onclick = function(){

        // 提前拼接url，准备使用get方式发起请求
        url += `?username=${un.value}&password=${pw.value}`;

        const xhr = new XMLHttpRequest();
        xhr.open("get", url);
        xhr.onreadystatechange = function(){
            if(xhr.readyState === 4 && xhr.status === 200){
                console.log(xhr.responseText);
            }
        }
        xhr.send();

    }

    
</script>
</html>